package com.yazi.mxz.gather.main.goods;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.util.EntityUtils;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yazi.mxz.gather.common.App;
import com.yazi.mxz.gather.entity.http.GdcmtzResBody;
import com.yazi.mxz.gather.entity.repository.GdcmtzLog;
import com.yazi.mxz.gather.entity.repository.Product;
import com.yazi.mxz.gather.repository.GdcmtzLogRepository;
import com.yazi.mxz.gather.repository.ProductRepository;

public class GdcmtzCom extends Thread {

	static ObjectMapper om;
	static {

		om = new ObjectMapper();
		om.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
	}

	@Override
	public void run() {
		
		GdcmtzLogRepository gdcmtzLogRepository = App.context.getBean(GdcmtzLogRepository.class);
		GdcmtzLog log = gdcmtzLogRepository.findOne(GdcmtzLog.ID);
		if (null == log) {
			log = new GdcmtzLog();
			log.setId(GdcmtzLog.ID);
			log.setCur(1l);
			log.setEnd((long) Integer.MAX_VALUE);
			gdcmtzLogRepository.insert(log);
		}
		String[] ids = "65761,64274,64826,65363,60435,60418,65667,60423,62400,64547,60440,62855,64042,64792,65765,61494,65186,64646,64825,63531,65714,60977,65709,60429,61719,62399,62617,62946,63904,63049,60436,61146,63278,64647,60725,63467,65881,63247,60860,64018,64109,63357,60438,64199,65499,65412,65140,65622,65356,65768,61112,64139,62047,63751,60428,61722,65627,61733,65588,65256,64134,65141,65073,65364,65000,63995,65600,63462,64691,65812,62781,65944,62626,64061,64108,63546,65844,64060,64188,65750,61744,64565,65485,64919,62941,65628,64804,65585,61446,60623,65501,65693,65187,65309,60853,65776,65931,64760,60432,63574,64099,63683,63470,61850,64236,60553,61938,60422,63698,65590,65592,65723,65811,63096,62453,63932,63417,65071,65198,60424,65593,64661,61825,63595,63948,65595,65523,65601,64111,64614,65626,60517,61445,61462,60787,64089,62873,64137,65289,65669,64289,63748,64091,60806,64248,65876,63797,65868,64074,64347,65025,61480,61971,62204,63461,61360,63976,64141,65932,65597,65197,62837,63188,64187,65923,65633,64595,65072,63001,64586,65255,65786,65599,64138,65524,64216,64729,65818,63379,60419,60468,64169,65519,64090,64613,65317,63411,60852,63857,65809,65817,62217,62224,65188,65404,65908,65645,62021,63986,65620,60420,65394,64164,65512,65770,61236,65521,64677,60421,64559,62070,65882,62954,64389,65594,62627,65252,63518,63898,65390,62660,65520,65251,65304,65877,60427,61083,65864,63964,65692,65796,61626,65576,61743,64235,61751,63881,61365,64494,65866,65598,62327,64682,64728,65849,62374,65583,60784,65410,63769,64727,65375,65473,61021,61148,64645,63050,65195,65618,65736,62255,63880,64509,63381,61000,65301,65873,60826,64730,64543,63757,63418,60690,64495,65527,60807,60824,62154,62278,62657,64525,60715,63212,65584,61749,64112,61239,64989,60736,62599,64045,65316,63227,65587,65623,65784,61068,62036,64356,64833,65180,64133,65502,65743,65752,65446,61990,63556,60599,65474,65357,62335,65308,60469,64776,65880,60461,62387,65591,65788,62117,62172,64450,61594,65086,65445,63377,64867,61069,63975,64288,64390,65196,65193,63606,63678,60780,62040,63051,62148,65500,60460,60770,64140,64676,65087,61346,61723,62600,63967,64427,63530,65027,65903,65679,65865,63858,63906,65879,61768,64483,65636,60547,63996,65192,61226,65822,62095,64536,65254,65261,65722,65774,63335,63336,64019,64439,65014,63963,64327,65506,62949,65860,63912,65407,63409,65148,65609,65859,63658,65518,62388,62618,63259,65194,65507,62927,64379,64446,65517,61338,62279,61070,61977,63668,64151,65475,64204,65248,65510,65780,65134,60858,64208,60974,61501,64834,61368,65302,65448,64069,65810,60481,61789,64445,65062,65619,60459,60480,61372,65753,62049,63266,64217,65848,61176,65299,65861,61067,62020,65872,65142,64186,64476,65701,61319,62391,63883,65401,65437,62925,62948,65793,60846,65240,64014,60881,63406,63838,65578,65794,60457,60425,60426,60431,60434,60439,60442,60443,60444,60447,60448,60455,60458,60462,60464,60465,60467,60470,60479,60482,60483,60485,60486,60488,60489,60490,60492,60495,60507,60508,60516,60519,60520,60521,60522,60530,60533,60537,60538,60540,60541,60542,60543,60544,60548,60552,60556,60557,60558,60559,60560,60561,60562,60565,60566,60569,60570,60571,60572,60573,60590,60594,60596,60597,60598,60601,60602,60603,60604,60606,60607,60610,60611,60613,60614,60615,60616,60618,60619,60620,60621,60626,60629,60630,60631,60634,60635,60636,60638,60655,60656,60658,60659,60662,60663,60664,60666,60669,60670,60671,60672,60673,60674,60675,60676,60680,60681,60683,60688,60692,60694,60706,60707,60709,60712,60713,60716,60717,60718,60731,60732,60735,60738,60774,60775,60776,60777,60779,60783,60788,60789,60792,60793,60794,60800,60801,60803,60804,60805,60809,60814,60816,60822,60825,60827,60845,60851,60854,60856,60857,60859,60861,60866,60867,60873,60875,60876,60878,60884,60886,60889,60901,60903,60904,60907,60908,60909,60913,60919,60930,60933,60952,60953,60954,60961,60962,60963,60970,60971,60973,60978,60979,60980,60989,60990,60991,60992,60998,60999,61005,61017,61019,61020,61022,61024,61027,61031,61041,61047,61049,61051,61052,61053,61056,61057,61058,61063,61064,61073,61074,61076,61078,61082,61084,61086,61088,61089,61092,61093,61094,61102,61103,61104,61105,61106,61107,61108,61109,61111,61113,61114,61122,61123,61124,61125,61126,61129,61136,61137,61138,61143,61145,61147,61150,61152,61153,61162,61165,61166,61169,61173,61174,61175,61187,61192,61193,61196,61197,61201,61203,61204,61205,61206,61211,61213,61215,61216,61217,61218,61219,61220,61229,61230,61231,61232,61233,61234,61235,61238,61240,61243,61245,61250,61253,61254,61258,61259,61260,61261,61273,61274,61275,61286,61299,61301,61302,61316,61317,61318,61320,61321,61324,61325,61333,61336,61337,61339,61341,61342,61343,61345,61347,61348,61349,61350,61351,61352,61353,61354,61355,61356,61358,61359,61362,61363,61366,61371,61374,61375,61382,61383,61385,61388,61389,61390,61391,61397,61412,61414,69079,61439,61440,61441,61444,61447,61449,61450,61457,61459,61460,61461,61463,61466,61477,61479,61483,61484,61486,61488,61490,61491,61492,61493,61495,61497,61498,61499,61500,61502,61503,61504,61505,61510,61512,61514,61517,61519,61533,61534,61542,61552,61558,61559,61561,61562,61569,61577,61582,61593,61595,61599,61602,61613,61616,61619,61621,61622,61624,61625,61627,61635,61643,61664,61665,61667,61680,61689,61697,61698,61700,61701,61703,61704,61705,61708,61709,61711,61713,61717,61724,61732,61735,61736,61737,61738,61739,61740,61745,61746,61747,61752,61755,61759,61760,61761,61762,61763,61765,61766,61767,61769,61770,61771,61781,61782,61784,61788,61791,61817,61821,61823,61829,61831,61832,61834,61835,61836,61837,61838,61839,61841,61842,61844,61845,61846,61847,61851,61856,61857,61859,61860,61861,61862,61863,61866,61867,61868,61871,61873,61877,61890,61895,61897,61898,61899,61903,61905,61911,61917,61924,61925,61929,61930,61931,61932,61933,61936,61940,61941,61947,61948,61949,61950,61954,61955,61956,61957,61963,61967,61968,61969,61970,61973,61974,61976,61978,61980,61982,61988,61991,61993,61999,62003,62004,62005,62006,62008,62014,62023,62034,62038,62041,62042,62054,62055,62057,62058,62061,62062,62063,62064,62066,62067,62068,62069,62073,62074,62075,62080,62081,62085,62091,62093,62094,62096,62099,62103,62104,62105,62108,62109,62110,62111,62112,62115,62116,62122,62123,62124,62127,62130,62131,62132,62133,62137,62140,62147,62149,62151,62157,62159,62160,62161,62162,62163,62169,62171,62175,62176,62177,62179,62181,62182,62192,62195,62196,62200,62201,62202,62203,62205,62208,62210,62211,62212,62213,62216,62218,62219,62220,62221,62222,62223,62225,62228,62229,62247,62249,62250,62254,62256,62257,62259,62266,62267,62271,62277,62280,62282,62284,62285,62286,62287,62308,62309,62315,62317,62318,62325,62326,62328,62329,62331,62332,62333,62336,62342,62343,62346,62347,62349,62352,62357,62360,62361,62362,62363,62365,62366,62367,62368,62370,62376,62377,62378,62379,62382,62383,62384,62385,62386,62389,62390,62392,62397,62404,62405,62407,62412,62413,62416,62418,62424,62425,62426,62428,62429,62432,62436,62437,62447,62449,62450,62452,62454,62457,62462,62465,62467,62470,62480,62481,62482,62495,62497,62499,62518,62523,62526,62527,62528,62529,62530,62533,62534,62537,62539,62541,62542,62543,62546,62547,62551,62552,62553,62554,62556,62558,62559,62561,62563,62564,62571,62572,62573,62587,62591,62592,62593,62594,62595,62596,62598,62602,62603,62604,62605,62615,62616,62623,62625,62628,62663,62664,62665,62668,62671,62672,62673,62674,62675,62676,62677,62678,62679,62682,62683,62684,62685,62691,62692,62701,62703,62704,62705,62706,62719,62720,62721,62722,62723,62725,62726,62730,62731,62732,62744,62746,62756,62758,62760,62762,62763,62764,62766,62767,62772,62785,62786,62787,62788,62789,62791,62792,62793,62794,62821,62834,62840,62841,62844,62845,62850,62872,62874,62875,62877,62878,62884,62885,62890,62891,62892,62893,62894,62896,62903,62905,62906,62907,62908,62909,62911,62915,62916,62917,62919,62920,62924,62926,62928,62929,62932,62933,62935,62937,62940,62942,62943,62944,62947,62951,62952,62953,62955,62956,62964,62965,62968,62971,62973,62974,62975,62977,62980,62981,62982,62983,62988,62990,62992,62995,63003,63004,63005,63006,63008,63009,63010,63011,63012,63022,63026,63031,63033,63035,63043,63044,63048,63058,63063,63085,63088,63089,63095,63102,63103,63107,63110,63113,63123,63124,63125,63126,63127,63129,63133,63134,63136,63139,63140,63141,63143,63144,63155,63156,63157,63159,63160,63167,63173,63174,63176,63177,63180,63185,63186,63187,63191,63192,63193,63194,63195,63196,63202,63203,63204,63205,63210,63211,63213,63219,63220,63222,63223,63224,63226,63233,63235,63236,63237,63240,63246,63249,63250,63252,63260,63261,63262,63263,63264,63265,63274,63275,63277,63279,63285,63286,63297,63298,63302,63303,63305,63307,63309,63310,63313,63315,63316,63319,63320,63321,63322,63323,63325,63326,63327,63328,63330,63331,63337,63338,63339,63340,63341,63342,63359,63370,63373,63387,63389,63390,63395,63404,63405,63408,63410,63412,63413,63414,63415,63424,63425,63426,63427,63429,63430,63433,63435,63440,63442,63443,63445,63447,63448,63451,63453,63454,63460,63463,63465,63466,63472,63474,63477,63478,63480,63487,63488,63489,63491,63493,63495,63496,63499,63503,63504,63505,63506,63508,63510,63511,63512,63515,63516,63517,63519,63522,63525,63526,63528,63535,63538,63539,63542,63543,63545,63547,63553,63554,63557,63558,63560,63561,63562,63563,63564,63566,63570,63571,63572,63583,63584,63599,63600,63601,63603,63607,63608,63610,63611,63612,63614,63615,63616,63627,63631,63632,63633,63635,63637,63638,63639,63640,63642,63652,63653,63661,63662,63663,63664,63665,63666,63667,63671,63673,63674,63677,63681,63682,63686,63687,63688,63690,63692,63693,63694,63697,63705,63715,63717,63720,63723,63725,63726,63727,63728,63734,63736,63740,63753,63755,63758,63762,63763,63765,63766,63767,63770,63771,63772,63781,63792,63796,63798,63805,63808,63812,63816,63836,63837,63840,63843,63844,63845,63859,63862,63863,63864,63865,63868,63869,63870,63872,63873,63876,63877,63878,63879,63882,63884,63885,63886,63887,63888,63890,63895,63897,63899,63900,63905,63907,63909,63910,63911,63913,63914,63917,63920,63921,63926,63927,63929,63930,63931,63933,63934,63935,63941,63942,63946,63947,63949,63952,63953,63954,63956,63961,63962,63965,63966,63968,63969,63970,63971,63973,63974,63977,63979,63980,63981,63983,63984,63988,63992,63993,63994,63997,63998,64001,64003,64004,64007,64009,64011,64015,64020,64022,64025,64032,64033,64034,64036,64043,64044,64046,64051,64059,64062,64063,64064,64067,64068,64070,64071,64072,64073,64075,64076,64078,64079,64080,64083,64085,64086,64087,64088,64092,64093,64095,64096,64097,64098,64101,64105,64106,64107,64114,64118,64123,64124,64125,64130,64131,64135,64136,64142,64143,64148,64150,64154,64155,64156,64157,64159,64160,64161,64170,64171,64172,64174,64175,64177,64178,64182,64190,64191,64192,64193,64194,64197,64198,64200,64201,64202,64203,64205,64207,64209,64210,64213,64214,64215,64218,64219,64220,64221,64222,64223,64224,64226,64227,64232,64233,64234,64237,64238,64239,64242,64243,64244,64246,64252,64253,64254,64256,64257,64258,64261,64263,64264,64268,64269,64270,64275,64278,64279,64280,64283,64284,64286,64290,64291,64292,64296,64297,64298,64300,64303,64304,64305,64306,64307,64311,64313,64314,64315,64316,64317,64320,64321,64322,64324,64325,64326,64332,64333,64334,64335,64336,64337,64343,64344,64345,64346,64352,64354,64357,64358,64360,64361,64362,64364,64365,64369,64370,64374,64376,64377,64378,64380,64381,64382,64384,64385,64386,64392,64394,64409,64410,64411,64412,64413,64418,64420,64421,64425,64428,64429,64430,64431,64433,64434,64435,64436,64440,64441,64443,64444,64447,64448,64451,64452,64453,64454,64459,64461,64462,64463,64473,64474,64475,64477,64479,64480,64481,64482,64484,64486,64487,64488,64491,64492,64496,64497,64498,64499,64500,64501,64502,64505,64506,64508,64510,64511,64516,64517,64518,64519,64520,64521,64526,64528,64529,64530,64532,64534,64537,64538,64539,64540,64541,64542,64545,64548,64553,64554,64556,64557,64558,64560,64561,64562,64563,64564,64566,64567,64568,64569,64570,64571,64573,64574,64575,64576,64578,64579,64580,64581,64582,64583,64584,64585,64587,64598,64601,64605,64607,64608,64609,64612,64615,64616,64617,64618,64619,64620,64621,64622,64623,64625,64626,64627,64628,64629,64635,64636,64637,64638,64639,64640,64641,64644,64650,64651,64652,64654,64655,64656,64658,64660,64662,64663,64664,64665,64666,64667,64668,64669,64670,64671,64672,64673,64674,64679,64681,64683,64685,64686,64687,64688,64689,64690,64701,64702,64703,64704,64705,64706,64707,64708,64709,64710,64711,64717,64718,64720,64721,64722,64723,64724,64726,64731,64734,64736,64751,64752,64753,64754,64755,64756,64757,64758,64759,64767,64768,64769,64770,64772,64773,64774,64775,64779,64784,64788,64790,64791,64794,64795,64796,64797,64798,64799,64800,64801,64802,64803,64805,64806,64815,64817,64818,64820,64824,64828,64830,64831,64832,64835,64837,64838,64839,64840,64842,64843,64844,64845,64846,64847,64848,64850,64851,64852,64857,64859,64860,64862,64864,64865,64866,64868,64869,64870,64871,64872,64873,64874,64875,64876,64878,64880,64883,64884,64885,64886,64887,64888,64889,64890,64891,64892,64893,64897,64899,64900,64901,64904,64905,64907,64908,64909,64912,64913,64915,64918,64920,64921,64922,64923,64924,64925,64926,64927,64928,64929,64930,64931,64934,64938,64939,64940,64941,64942,64943,64945,64946,64948,64951,64953,64955,64956,64957,64958,64959,64962,64963,64964,64965,64966,64967,64969,64970,64971,64972,64973,64975,64976,64977,64978,64979,64980,64981,64982,64984,64985,64990,64991,64992,64993,64994,64996,64998,64999,65001,65002,65003,65004,65005,65006,65007,65008,65009,65010,65012,65013,65015,65016,65017,65018,65020,65021,65022,65023,65024,65026,65028,65029,65030,65031,65032,65033,65034,65035,65036,65045,65046,65047,65048,65049,65050,65051,65052,65054,65056,65057,65058,65060,65063,65064,65065,65070,65074,65075,65076,65077,65078,65079,65080,65081,65082,65083,65084,65085,65088,65089,65090,65092,65093,65094,65095,65096,65098,65100,65101,65103,65104,65105,65106,65107,65108,65109,65110,65111,65113,65114,65115,65117,65118,65120,65122,65123,65127,65128,65129,65130,65131,65132,65133,65135,65136,65139,65143,65144,65145,65146,65147,65149,65150,65151,65152,65153,65154,65155,65156,65157,65158,65159,65163,65164,65165,65166,65167,65168,65169,65171,65172,65173,65174,65175,65177,65178,65179,65181,65182,65183,65184,65185,65190,65191,65199,65200,65201,65202,65203,65204,65205,65206,65210,65211,65212,65213,65214,65216,65217,65218,65219,65220,65221,65222,65223,65224,65226,65227,65228,65229,65230,65231,65232,65233,65234,65235,65236,65237,65238,65239,65243,65244,65247,65249,65257,65258,65259,65260,65262,65263,65264,65265,65266,65267,65269,65270,65271,65272,65273,65274,65275,65276,65277,65278,65279,65281,65282,65283,65285,65288,65290,65291,65292,65293,65294,65297,65298,65300,65303,65305,65306,65310,65311,65312,65313,65318,65320,65321,65322,65323,65324,65325,65326,65327,65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,65339,65340,65341,65342,65343,65344,65347,65349,65351,65352,65358,65359,65360,65361,65362,65365,65366,65367,65368,65369,65370,65371,65372,65373,65374,65377,65384,65385,65386,65387,65388,65389,65391,65392,65393,65398,65399,65400,65402,65403,65405,65406,65408,65409,65411,65413,65414,65415,65416,65417,65418,65419,65420,65421,65422,65423,65425,65427,65428,65429,65432,65433,65434,65435,65436,65438,65439,65440,65441,65442,65443,65444,65447,65449,65456,65462,65463,65464,65465,65466,65467,65468,65469,65470,65471,65472,65478,65479,65482,65483,65486,65487,65490,65491,65492,65494,65495,65496,65497,65498,65503,65504,65505,65508,65509,65511,65513,65514,65516,65525,65526,65528,65529,65530,65546,65547,65548,65549,65550,65551,65553,65554,65555,65556,65563,65564,65565,65575,65579,65580,65581,65582,65589,65602,65603,65604,65605,65606,65608,65611,65612,65614,65617,65621,65625,65629,65632,65634,65635,65637,65642,65643,65644,65646,65647,65648,65649,65650,65651,65652,65653,65654,65655,65656,65657,65658,65659,65660,65663,65664,65668,65670,65671,65676,65677,65678,65680,65681,65683,65684,65685,65686,65687,65689,65690,65694,65696,65697,65698,65700,65702,65704,65705,65706,65707,65708,65710,65711,65712,65713,65715,65716,65717,65718,65719,65720,65721,65724,65725,65726,65727,65728,65729,65730,65731,65733,65734,65737,65738,65739,65740,65741,65742,65744,65745,65746,65747,65748,65749,65751,65754,65755,65756,65757,65760,65764,65769,65771,65772,65773,65778,65779,65781,65782,65783,65787,65789,65790,65791,65792,65795,65797,65798,65799,65800,65801,65802,65803,65804,65805,65806,65807,65808,65813,65814,65815,65816,65823,65827,65828,65837,65839,65841,65842,65845,65846,65847,65850,65851,65852,65853,65854,65855,65856,65857,65858,65863,65867,65869,65870,65871,65874,65875,65878,65883,65885,65886,65889,65891,65892,65895,65896,65897,65898,65899,65900,65905,65910,65911,65912,65913,65917,65918,65919,65920,65922,65927,65928,65929,65930,65935,65936,65938,65939,65940,65942,65943,65946,65948,65950,65951,66179,65953,65954,65957,66106,65968,65970,65971,65972,65974,65975,65976,65982,65986,65987,65988,65989,65995,65997,66011,66013,66014,66107,66108,66112,66115,66117,66119,66123,66127,66132,66133,66136,66137,66140,66141,66142,66143,66144,66145,66146,66150,66154,66155,66156,66157,66160,66161,66162,66167,66172,66177,66178,66180,66200,66208,66213,66217,66218,66219,66220,66222,66223,66225,66230,66231,66232,66241,66242,66250,69078,66252,69077,66254,66257,66258,66261,66262,66263,66264,66269,66270,66271,66272,66273,66274,66275,66276,66280,69085,68986,66323,66705,69076,66381,66382,69198,66406,66412,66413,66414,66418,66419,66420,66421,66422,66423,66426,66427,66428,66429,66432,66434,66435,66437,66438,66442,66450,66451,66452,66453,66454,66455,66456,66457,66458,66459,66632,66491,66492,66493,66494,66495,66496,66500,66503,66505,66514,66517,66518,66521,66523,66524,66531,66532,66533,66534,66535,66536,66537,66554,66540,66541,66544,66545,66547,66550,66551,69195,66555,68985,66602,66598,66600,66601,66603,66606,66609,66613,66614,69391,66681,66695,66696,66697,66698,66699,66700,66701,66703,66704,66970,67146,67148,67162,67250,67282,67308,67310,67311,67394,67395,68996,69002,69003,69126,69065,69068,69070,69072,69074,69075,69086,69087,69089,69090,69091,69092,69093,69094,69197,69193,69196,69204,69205,69208,69220,69227,69235,69238,69239,69240,69241,69242,69243,69244,69247,69342,69484,69488,69489,69490,69502,69503,69505,69506,69507,69513,69516,69517,69519,69521,69525,69527,69528,69529,69636,69638,69761,69762,83140,69936,69964,70422,71465,71859,71860,73208,73592,73640,73750,74440,74792,74827,74983,77389,77677,77678,77684,79240,79461,79527,81669,81759,81781,81980,82198,82199,82206,82207,82269,82268,82263,82262,82260,82245,82244,82233,82232,82231,82223,82222,82290,82291,82336,82303,82306,82307,82308,82309,82310,82311,82312,82313,82315,82316,82317,82318,82322,82338,82339,82340,82341,82342,82345,82346,82344,82356,82365,82366,82367,82379,82380,82381,82384,82385,82386,82387,82388,82389,82390,82391,82392,82437,82438,82439,82440,82443,82444,82447,82448,82466,82467,82468,82472,82473,82474,82476,82477,82478,82479,82486,82487,82488,82489,82490,82492,82493,82503,82504,82505,82506,82507,82508,82509,82510,82540,82541,82542,82543,82544,82568,82569,82576,82577,82580,82581,82583,82585,82586,82587,82589,82590,82593,82595,82596,82616,82617,82618,82619,82621,82622,82623,82641,82649,82653,82654,82657,82660,82662,82663,82683,82666,82669,82682,82684,82685,82686,82687,82743,82744,82767,82772,82773,82774,82775,82776,82777,82779,82780,82781,82782,82783,82784,82785,82787,82788,82790,82791,82792,82793,82794,82795,82800,82797,82801,82808,82809,82811,82812,82819,82821,82838,82839,82840,82842,82848,82850,82851,82852,82853,82855,82856,82857,82858,82859,82862,82864,82865,82866,82867,82868,82869,82871,82872,82873,82876,82877,82878,82879,82880,82881,82882,82952,82927,82928,82929,82930,82931,82933,82934,82938,82939,82941,82947,82953,82954,82956,82957,82958,82959,82960,82961,82962,82965,82967,82968,82981,82986,82987,82989,82998,82999,83000,83001,83004,83008,83102,83103,83105,83111,83112,83113,83114,83117,83118,83119,83120,83121,83127,83128,83129,83130,83131,83132,83133,83135,83136,83141,83142,83159,83196,83445,83939,83940,83953,83954,83955,84306,84307,65945,60592,60612,60771,60778,60821,60924,60925,60926,60927,60928,60931,61029,61164,61184,61190,61237,61268,61283,61285,61292,61294,61295,61300,61323,61386,61485,61515,61535,61540,61637,61646,61647,61691,61692,61750,61764,61843,61889,61909,61913,62244,62322,62334,62364,62396,62614,62661,62734,62780,62782,62783,62851,62852,62853,63086,63117,63118,63121,63393,63394,63485,63549,63644,63729,63730,63731,63732,63756,63799,64037,64047,64052,64053,64054,64081,64082,64149,64206,64212,64225,64250,64251,64266,64339,64340,64341,64342,64348,64349,64366,64383,64399,64442,64449,64460,64472,64478,64524,64552,64606,64684,64697,64765,64836,64849,64902,64903,64911,64988,65011,65066,65091,65119,65121,65124,65125,65395,65457,65458,65459,65460,65461,65688,65691,65824,65836,65843,65904,65924,65925,65926,65941,65949,65996,66079,66080,66081,66082,66083,66084,66085,66086,66087,66088,66089,66090,66091,66092,66093,66094,66095,66096,66097,66098,66099,66100,66101,66102,66103,66104,66105,66281,66287,69418,66449,66403,69286,66439,66440,66441,66461,66497,66498,66506,66508,66525,66526,66527,66528,66548,66549,66552,66553,66556,66585,69412,66720,66721,66793,67166,67258,67281,67526,67527,67528,67532,68977,69049,69050,69051,69052,69056,69107,69194,69206,69321,69287,69292,69294,69308,69312,69313,69314,69315,69316,69317,69319,69320,69327,69329,69330,69331,69333,69335,69336,69337,69338,69339,69341,69358,69359,69360,69361,69362,69365,69368,69369,69370,69372,69374,69396,69397,69400,69401,69405,69408,69413,69414,69415,69429,69511,69520,69601,69600,69599,69598,69588,69585,69584,69583,69579,69576,69574,69573,69572,69571,69570,69602,69603,69604,69616,69622,69623,69627,69628,69629,69630,69631,69633,69639,69640,69642,69643,69644,69645,69646,69647,69648,69649,69650,69651,69652,69653,69654,69655,69656,69657,69658,69659,69660,69661,69663,69665,69666,69667,69668,69669,69670,69671,69672,69673,69674,69675,69676,69677,69678,69679,69680,69681,69682,69683,69684,69685,69686,69687,69688,69689,69690,69691,69692,69693,69694,69695,69696,69697,69698,69699,69700,69701,69702,69703,69704,69705,69706,69707,69708,69709,69710,69711,69712,69714,69715,69716,69717,69718,69719,69720,69721,69722,69723,69724,69725,69726,69727,69728,69729,69730,69731,69732,69733,69734,69735,69736,69737,69738,69739,69740,69741,69742,69743,69744,69745,69746,69747,69748,69749,69750,69751,69752,69763,69764,69765,69766,69767,69768,69769,69770,69771,69772,69774,69775,69776,69777,69779,69782,69783,69784,69786,69787,69788,69790,69791,69793,69794,69795,69798,69799,69800,69821,69823,69824,69825,69833,69843,69844,69845,84613,69903,69916,69920,69925,69961,69974,69975,69976,70468,70701,71094,71285,71387,71982,71983,72103,72209,72254,72594,72644,72896,72947,72972,73190,73680,75189,75787,76397,77403,77420,77795,77917,77941,78058,78780,78927,79061,79676,80304,81345,83640,83646,83642,83641,83639,83453,84160,82259,82258,82257,82256,82255,82254,82253,82252,82251,82250,82249,82248,82247,82296,82347,82350,82351,82352,82353,82354,82355,82357,82358,82359,82424,82425,82442,82613,82614,82615,82624,82642,82643,82644,82645,82646,82647,82651,82652,82748,82749,82883,82884,82902,82903,82904,82910,82915,82917,82918,82919,82935,82936,82940,82974,82975,82983,82984,82988,83951,83007,83009,83039,83041,83042,83043,83044,83055,83056,83080,83081,83148,83149,83181,83190,83193,83216,83205,83210,83211,83212,83213,83214,83217,83218,83248,83249,83250,83251,83252,83253,83254,83255,83256,83257,83258,83259,83260,83261,83262,83263,83264,83265,83266,83267,83268,83269,83270,83287,83274,83275,83277,83278,83279,83280,83281,83282,83286,83591,83311,83312,83313,83314,83315,83316,83317,83318,83323,83324,83325,83326,83331,83332,83334,83335,83336,83337,83338,83339,83341,83342,83345,83346,83347,83405,83406,83407,83408,83409,83431,83433,83434,83435,83436,84405,83454,83455,83456,83458,83459,83466,83467,83468,83469,83471,83474,83478,83481,83483,83484,83485,83486,83487,83488,84358,83493,83494,83495,83496,83501,83502,83513,83514,83515,83521,83522,83532,83533,83534,83535,83536,83537,83538,83539,83540,83541,83542,83543,83544,83545,83546,83547,83552,83548,83549,83562,83550,83551,83553,83554,83555,83556,83557,83558,83559,83560,83561,83568,83569,83570,83571,83572,83573,83574,83576,83577,83578,83581,83582,83583,83584,83585,83586,83588,83589,83590,83592,83593,83594,83595,83596,83637,83634,83648,83649,83650,83651,83652,83653,83655,83656,83657,83658,83659,83660,83661,83662,83663,83664,83667,83668,83669,83670,83672,83677,83678,83679,83680,83682,83683,83684,83729,83742,83744,83745,83746,83747,83748,83749,83750,83751,83752,83753,83754,83755,83756,83758,83759,83760,83761,83762,83763,83764,83765,83766,83770,83771,83772,83773,83774,83788,83789,83790,83791,83792,83793,83794,83807,83811,83812,83817,83832,83853,83878,83879,83880,83881,83882,83883,83884,83885,83886,83887,83890,83891,83892,83893,83894,83895,83896,83898,83899,83900,83901,83902,83903,83905,83906,83907,83908,83909,83910,83911,83915,83916,83917,83918,83919,83920,83921,83922,83923,83924,83925,83926,83927,83952,83982,83983,83984,83985,83986,83987,83988,83989,83990,83991,83992,83994,83995,83996,83999,84000,84001,84002,84003,84014,84015,84016,84021,84022,84026,84027,84028,84029,84030,84031,84032,84033,84034,84035,84036,84037,84039,84040,84041,84043,84045,84046,84047,84052,84054,84055,84056,84057,84058,84059,84060,84061,84062,84063,84064,84065,84066,84070,84071,84072,84073,84074,84075,84076,84077,84085,84086,84087,84088,84089,84090,84093,84094,84095,84096,84110,84111,84112,84113,84114,84115,84116,84117,84118,84119,84120,84121,84122,84123,84124,84125,84126,84127,84128,84129,84130,84131,84132,84133,84134,84136,84138,84140,84141,84142,84143,84144,84145,84149,84158,84162,84164,84173,84174,84182,84183,84184,84185,84186,84187,84188,84189,84191,84192,84193,84194,84198,84199,84200,84201,84202,84203,84204,84205,84206,84207,84208,84209,84210,84211,84212,84213,84214,84215,84216,84217,84218,84219,84220,84221,84222,84223,84224,84225,84226,84227,84229,84230,84231,84232,84233,84234,84235,84236,84237,84238,84239,84240,84241,84242,84243,84244,84245,84246,84247,84248,84249,84250,84251,84252,84253,84254,84255,84256,84271,84272,84275,84279,84282,84283,84286,84287,84293,84294,84295,84296,84297,84298,84299,84300,84301,84302,84303,84304,84305,84308,84309,84310,84311,84312,84313,84314,84315,84316,84320,84321,84324,84326,84330,84331,84333,84334,84335,84336,84337,84338,84339,84340,84341,84342,84343,84344,84347,84359,84361,84362,84363,84364,84365,84366,84367,84369,84370,84371,84372,84373,84374,84375,84376,84377,84378,84379,84380,84381,84382,84383,84384,84385,84386,84387,84388,84389,84390,84391,84392,84393,84401,84402,84403,84404,84406,84409,84410,84411,84412,84413,84414,84415,84416,84417,84422,84418,84419,84420,84421,84423,84424,84425,84426,84427,84428,84429,84430,84431,84432,84433,84434,84435,84436,84437,84438,84439,84440,84442,84443,84444,84445,84446,84465,84466,84467,84468,84469,84470,84471,84472,84473,84477,84474,84478,84480,84481,84484,84485,84486,84487,84488,84489,84490,84491,84492,84493,84494,84495,84496,84497,84498,84499,84500,84501,84502,84503,84504,84505,84506,84507,84508,84509,84510,84511,84512,84513,84514,84515,84516,84517,84518,84519,84522,84523,84524,84527,84528,84530,84531,84532,84533,84541,84542,84543,84544,84545,84546,84547,84548,84549,84550,84551,84558,84562,84563,84564,84565,84567,84568,84569,84570,84571,84572,84573,84574,84575,84576,84577,84578,84579,84580,84581,84582,84583,84584,84585,84586,84587,84588,84589,84590,84591,84592,84593,84594,84595,84596,84610,84608,84611,84612,84614,84615,84616,84617,84622,84623,84629,84630,84631,84632,84634,84635,84639,84640,84641,84642,84643,84645,84646,84647,84648,84649,84650".split(","); 
		//log.setCur(1l);
		//log.setEnd((long)ids.length);
		while (true) {
			if (log.getCur() >= log.getEnd()) {
				break;
			}
			try {
				barcodeInfo(Long.parseLong(ids[log.getCur().intValue()]));
			} catch (Exception e) {
				e.printStackTrace();
				break;
			}
			log.setCur(log.getCur() + 1);
			gdcmtzLogRepository.save(log);
			/*
			try {
				sleep(300);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			*/
		}
		
	}

	private void barcodeInfo(long goodsId) throws JsonParseException, JsonMappingException,
			IOException, InterruptedException, ExecutionException {

		CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
		httpclient.start();
		
		final HttpGet req = new HttpGet("http://shop.gdcmtz.com/goodsapi.php?act=getGoodsInfo&goods_id=" + goodsId);
		req.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		Future<HttpResponse> future = httpclient.execute(req, null);
		HttpResponse res;
		try {
			res = future.get();
		} finally {
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		String body = EntityUtils.toString(res.getEntity());
		System.out.println(req.getRequestLine() + "->" + res.getStatusLine());
		System.out.println(body);

		if (body.isEmpty()) {
			System.out.println("无响应内容!");
			return;
		}

		GdcmtzResBody gdcmtz = om.readValue(body, GdcmtzResBody.class);
		GdcmtzResBody.Items items = gdcmtz.getItems();

		if (null == items.getGoodsId()) {
			System.out.println("商品不存在: " + goodsId);
			return;
		}

		ProductRepository productRepository = App.context.getBean(ProductRepository.class);

		String img = null;
		if (items.getGoodsImg().equals("/images/no_picture.gif")) {
			System.out.println("无图片:" + goodsId);
		} else {
			img = App.saveGoodsImage("http://shop.gdcmtz.com/" + items.getGoodsImg(), items.getBarcode());
		}

		if (!productRepository.exists(items.getBarcode())) {
			System.out.println("添加: " + items.getName());

			Product product = new Product();

			// product.setArea(items.getCountry());
			product.setBarcode(items.getBarcode());
			product.setBrandName(items.getBrandName());
			// product.setFacCode(items.getFacCode());
			// product.setFacName(items.getFacName());
			product.setIsCheckName(true);
			product.setName(items.getName());
			// product.setSpell(rs.getString("pinyin"));
			product.setPic(img);
			product.setPrice(items.getPrice());
			product.setUnit(items.getUnit());
			product.setSource("shop.gdcmtz.com");
			product.setSpec(items.getSpec());
			// product.setSupplier(items.getSupplier());
			product.setSysRemark(items.getGoodsId() + "|" + items.getCatId());

			productRepository.insert(product);

		} else {
			System.out.println("修改: " + items.getName());

			Product product = productRepository.findOne(items.getBarcode());

			if (null != items.getBrandName() && null == product.getBrandName()) {
				product.setBrandName(items.getBrandName());
			}
			if (null != items.getName() && null == product.getName()) {
				product.setName(items.getName());
			}
			if (null != img && null == product.getPic()) {
				product.setPic(img);
			}
			if (null != items.getPrice() && null == product.getPrice()) {
				product.setPrice(items.getPrice());
			}
			if (null != items.getUnit() && null == product.getUnit()) {
				product.setUnit(items.getUnit());
			}
			if (null != items.getSpec() && null == product.getSpec()) {
				product.setSpec(items.getSpec());
			}

			productRepository.save(product);

		}
	}

}
